package com.qf.controller;

import org.springframework.security.access.annotation.Secured;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * 主页
 * @author 千锋健哥
 */
@Controller
@RequestMapping("/home")
public class HomeController {

    /**
     * 登录成功后跳转到这里
     * @return
     */
    @RequestMapping("/info")
    @ResponseBody
    //基于角色的权限控制
    @Secured({"ROLE_normal","ROLE_devManager"})
    public String info() {
        return  "success";
    }

    /**
     * 基于角色的权限控制
     * @return
     */
    @RequestMapping("/test1")
    @ResponseBody
    @Secured({"ROLE_normal","ROLE_DEV"})
    public String test1() {
        return "test1";
    }

    @RequestMapping("/test2")
    //菜单权限字符串控制
    @PreAuthorize("hasAuthority('sys:dev:*')")
    @ResponseBody
    public String  test2() {
        return "test2";
    }

    /**
     * 登录失败跳转到这里
     * @return
     */
    @RequestMapping("/fail")
    @ResponseBody
    public String fail() {
        return  "error";
    }
}
